package com.yanyilu.qiubite.jpa;

import com.yanyilu.qiubite.entity.Code;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface CodeJpa extends JpaRepository<Code,Integer> {

     @Query(value ="select * from code where phone_number = :phoneNumber",nativeQuery = true)
     Code findByPhoneNumber(@Param("phoneNumber") String phoneNumber);

     @Query(value = "select * from code where phone_number = :phoneNumber and code = :code and end_time > :time",nativeQuery = true)
     Code findByPhoneNumberAndCode(@Param("phoneNumber")String phoneNumber, @Param("code") String code, @Param("time") Integer time);
}
